#ifndef tafang_LoadingPro_h
#define tafang_LoadingPro_h



#include "../PreInclude.h" 

class CLoadingItem{
    
public:
    string cFilePath;
    string cPngPath;
    bool bIsPlist;
    int loadIndex;
};


class  LoadingPro:public CCObject{
public :
    static LoadingPro* shareLoadingPro();
    ~LoadingPro();
    LoadingPro();
    
    void addItemLoadTarget(CCObject*,SEL_CallFuncO);
    void addAllLoadTarget(CCObject*,SEL_CallFunc);
    void addItem(const string& ,bool before =false);
    void load();
    
    int getTotalCount();
    int getLoadedCount();
    
    
    void updateGame(float dt);
    void clear();
    void clearTarget();
    
    void addTryPlist(string);
    bool isHasLoadPlist(string);
    void removeHasLoadPlist(string);
    void addCachePlist(string);
    void removeCachePlist();
    int nFrameStartTime;
protected:
    vector<string> plistCache;
    list<string> plistLoaded;
    list<string> tryPistCache;
    
    string getImgPath(const string& path);
    
    map<string, CLoadingItem*> m_pFileNames;
    list<CLoadingItem*> gItems;
    vector<CCObject*> gItemTarget;
    vector<SEL_CallFuncO> gItemSelector;
    vector<CCObject*> gAllTarget;
    vector<SEL_CallFunc> gAllSelector;
    int m_nLoadedIndex;
    int m_nLoadedTotalCount;
    void continueLoad();
    void onLoaded(CLoadingItem*);
    
};

#endif
